package org.example.liaoxuefeng;

import java.math.BigDecimal;

/**
 * 使用策略模式新增一种策略，允许在满100减20的基础上对Prime会员再打七折。
 *
 * @author: 默苍璃
 * @date: 2024-07-18 17:34
 */
public class OverAndPrimeDiscountStrategy implements DiscountStrategy {
    @Override
    public BigDecimal getDiscount(BigDecimal total) {

        // 超过100的折扣
        BigDecimal overDiscount = new OverDiscountStrategy().getDiscount(total);
        // 减去 超过100的折扣
        BigDecimal temp = total.subtract(overDiscount);
        // 会员折扣
        BigDecimal primaeDiscount = new PrimeDiscountStrategy().getDiscount(temp);
        // 总的折扣
        return overDiscount.add(primaeDiscount);

    }
}
